package com.aner.test.controller;
import com.aner.tester.controller.BaseControllerTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.aner.tester.utils.text.StringUtils;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


/**
 * PutTestControllerTest class
 * 
 * @author aner
 * @date 2020-12-27
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@AutoConfigureMockMvc
public class PutTestControllerTest extends BaseControllerTest
{

    @Test
    public void testTest() {
        String params = "{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.17818539337520056,'floatTest':0.38138562,'intTest':0,'longTest':0,'stringTest':'司狗狗的小0'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.put("/test/", jsonStr);
        
    }
    @Test
    public void testRequestBodyMapTest() {
        String params = "{'第告':'91','21小1':'4141','个东的0':'494','狗个小0尔':'6101'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.putBody("/testRequestBodyMap/", jsonStr);
        
    }
    @Test
    public void testRequestBodyListTest() {
        String params = "['1个安小','故故猪司司5','2个安狗狗']";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.putBody("/testRequestBodyList/", jsonStr);
        
    }
    @Test
    public void testRequestBodyLongTest() {
        String params = "0";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.putBody("/testRequestBodyLong/", jsonStr);
        
    }
    @Test
    public void testRequestParamListTest() {
        String params = "{'testList':['司第猪','小猪广尔猪2','个0','的小猪','广尔1告三']}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.put("/testRequestParamList/", jsonStr);
        
    }
    @Test
    public void testRequestParamDateTest() {
        String params = "{'testDate':'2020-12-27 21:28:36'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.put("/testRequestParamDate/", jsonStr);
        
    }
    @Test
    public void testRequestBodyDateTest() {
        String params = "1609075716146";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.putBody("/testRequestBodyDate/", jsonStr);
        
    }
    @Test
    public void testDateTest() {
        String params = "{'test':'2020-12-27 21:28:36'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.put("/testDate/", jsonStr);
        
    }
    @Test
    public void testBodyTest() {
        String params = "{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.2720531263338458,'floatTest':0.3520673,'intTest':0,'longTest':3,'strArray':['猪公','狗小猪猪小的'],'stringList':['1猫3安2','猪事猫个','安第的猫猪','司猫','小53的小小'],'stringTest':'尔司0小事广','testObjectArray':[{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.03428093858879355,'floatTest':0.24548382,'intTest':1,'longTest':0,'stringTest':'公广猫'},{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.1812595643125473,'floatTest':0.1564011,'intTest':0,'longTest':1,'stringTest':'3故狗5'},{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.8625817689191114,'floatTest':0.838703,'intTest':0,'longTest':3,'stringTest':'告个安小小的'}],'testObjectList':[{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.4927065173301197,'floatTest':0.18968028,'intTest':0,'longTest':2,'stringTest':'1事第的小'},{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.8765065761679087,'floatTest':0.23323578,'intTest':1,'longTest':3,'stringTest':'4第三狗'},{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.717925196550161,'floatTest':0.5174983,'intTest':1,'longTest':0,'stringTest':'41个尔'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.3556044562540355,'floatTest':0.3660286,'intTest':0,'longTest':1,'stringTest':'2公安狗第'}],'testObjectMap':{'司省猫猫司':'92571','个四广猪':'49334','2猪猪小':'104882','3第':'435499'}}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.putBody("/testRequestBody/", jsonStr);
        
    }
    @Test
    public void testPathVariableTest() {
        String params = "{'params':['故小','广公','四公02个','个公1狗安猫','四事'],'id':[3,3,3,3,1]}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.put("/testPathVariable/{params}/{id}", jsonStr);
        
    }
}
